public abstract class user 
{
	 String name;
	 int numTransaction;
	
	candyTransaction start;
	
	public user()
	{
		name = null;
		start = new candyTransaction();
		numTransaction = 0;
	}
	public user(String nam, int grad)
	{
		name = nam;
		start = new candyTransaction();
		numTransaction = 0;
	}
	

	
	public void buyCandy(double ammountIn, int a, int b, int c, int d)
	{
		candyTransaction current = new candyTransaction(ammountIn,a,b,c,d);
		getLast().setNext(current);
		numTransaction ++;
		System.out.println(current);
	}
	
	public void donate(double ammountIn)
	{
		donationTransaction current = new donationTransaction(ammountIn);
		getLast().setNext(current);
		numTransaction ++;
		System.out.println(current);
	}
	
	public transaction getLast()
	{
		return getLast(start);
	}
	
	private transaction getLast(transaction c)
	{
		if (c.getNext() == null)
			return c;
		return getLast(c.getNext());
	}
	
	public double getCost()
	{
		return getCost(start);
	}
	private double getCost(transaction c)
	{
		if (c.getNext() == null)
			return c.getCost();
		return getCost(c.getNext()) + c.getCost();
	}
	
	public double getProfit()
	{
		return getProfit(start);
	}
	private double getProfit(transaction c)
	{
		if (c.getNext() == null)
			return c.getProfit();
		return getProfit(c.getNext()) + c.getProfit();
	}
	
	public double getSpent()
	{
		return getSpent(start);
	}
	private double getSpent(transaction c)
	{
		if (c.getNext() == null)
			return c.getMoneyRecieved();
		return getSpent(c.getNext()) + c.getMoneyRecieved();
	}
	public String toString()
	{
		String temp = "";
		temp = 
			temp 
			+ "name: " + name
			+ " Transaction #: " + numTransaction
			+ " ammout Spent: " + getSpent()
			+ " total cost: " + getCost()
			+ " profit: " + getProfit();
		return temp;
	}
	public String getName()
	{
		return name;
	}
	

	
	
}
